package com.example.helloproject.controller;

import org.springframework.web.bind.annotation.*;
import java.util.HashMap;

@RestController
public class HelloController {
    @GetMapping("/hello")
    public String hello()
    {
        return "Hello SpringBoot: "+ nameAges.toString();
    }

    private static HashMap<String, Integer> nameAges = new HashMap<>();

    @PostMapping("/hello")
    public String helloPost(String name, int age)
    {
        nameAges.put(name, age);
        return "add name: "+ name + ", age= "+ age;
    }

    @PutMapping("/hello")
    public String helloPut(String name, int age)
    {
        nameAges.replace(name, age);
        return "update name: "+ name + ",age= "+ age;
    }

    @DeleteMapping("/hello/{name}")
    public String helloDel(@PathVariable String name)
    {
        nameAges.remove(name);
        return "delete name: "+ name;
    }
}
